<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE xsl:stylesheet SYSTEM "lang://blogs">

<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:output
		encoding="utf-8"
		indent="yes"
		doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
		omit-xml-declaration="yes"
		method="xml" />
		
	<xsl:param name="userId" select="@user-id" />
	<xsl:param name="typeName" select="data/response/@type-name" />
	<xsl:param name="objectId" select="data/response/@object-id" />
	<xsl:param name="baseURI" select="/data/@base-uri" />
	
	<xsl:template match="data/response">
		<h3>&labelBlogAdmins;</h3>
		<div id="blog_admins" class="blog_members_bosses">
			<xsl:if test="count (object[@type = 'blog_admin']) = 0">
				<xsl:text>&labelBlogsAdminsEmpty;</xsl:text>
			</xsl:if>
			<xsl:apply-templates select="object[@type = 'blog_admin']" mode="boss" />
		</div>
		
		<h3>&labelBlogModerators;</h3>
		<div id="blog_moderators" class="blog_members_bosses">
			<xsl:if test="count (object[@type = 'blog_moderator']) = 0">
				<xsl:text>&labelBlogModeratorsEmpty;</xsl:text>
			</xsl:if>
			<xsl:apply-templates select="object[@type = 'blog_moderator']" mode="boss" />
		</div>
		
		<h3>&labelBlogMembers;</h3>
		<xsl:choose>
			<xsl:when test="count (object[@type = 'blog_member']) = 0">
				<div>&labelBlogMembersEmpty;</div>
			</xsl:when>
			<xsl:otherwise>
				<ul id="blog_members">
					<xsl:apply-templates select="object[@type = 'blog_member']" mode="member" />
				</ul>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="response/object[@type = 'blog_admin' or @type = 'blog_moderator']" mode="boss">
		<xsl:param name="login" select="property[@name='user_login']/value" />
		<xsl:param name="avatar" select="property[@name='user_avatar']/value" />
		
		<div class="user_item">
			<div class="avatar">
				<a href="{$baseURI}/user/{$login}">
					<xsl:if test="$avatar != ''">
						<img src="{$baseURI}/thumb_50_50{$avatar}" alt="" />
					</xsl:if>
					<xsl:if test="$avatar = ''">
						<img src="{$baseURI}/images/default-avatar.png" alt="" />
					</xsl:if>
				</a>
			</div>
			<div class="user_name">
				<a href="{$baseURI}/user/{$login}">
					<xsl:value-of select="property[@name='user_name']/value" />
				</a>
			</div>
		</div>
	</xsl:template>
	
	<xsl:template match="response/object[@type = 'blog_member']" mode="member">
		<xsl:param name="login" select="property[@name='user_login']/value" />
		
		<li>
			<a href="{$baseURI}/user/{$login}">
				<xsl:value-of select="property[@name='user_name']/value" />
			</a>
		</li>
	</xsl:template>
	
</xsl:stylesheet>